package com.yan.demo.array;

public class ArrayDemo1 {
    public static void main(String[] args) {
        int[] arr = {5, 12, 90, 18, 77, 76, 45, 28, 59, 72};
        int max = arr[0];
        int index = -1;
        for (int i = 0; i < arr.length; i++) {
            if(arr[i] > max){
                max = arr[i];
                index =  i;
            }
        }
        System.out.println("max = " + max);
        System.out.println("最大值位置为" + (index + 1));
        // 找最小值
        int min = arr[0];
        index = -1;
        for (int i = 0; i < arr.length; i++) {
            if(arr[i] <= min){
                min = arr[i];
                index = i;
            }
        }
        System.out.println("min = " + min);
        System.out.println("最小值位置为" + index);
    }
}
